<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>slot-插槽</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  </head>

  <body>
    <!--  插槽，也就是slot，是组件的一块HTML模板，这块模板 显示不显示、以及 怎样显示 由父组件来决定 -->
    <!--  简而言之，插槽就是预留的空间（位置），即占位符 -->
    <div id="app">
      <con>
        <button>我是按钮</button>
      </con>
      <con></con>
      <con></con>
      <con></con>
    </div>
    <template id="tp">
      <div>
        <p>我是组件</p>
        <h3>我是组件哈哈哈</h3>
        <slot
          ><span>我是默认1</span><span>我是默认2</span><span>我是默认3</span
          ><button>我是默认</button></slot
        >
      </div>
    </template>
    <script>
      //创建Vue实例,得到 ViewModel
      var app = new Vue({
        el: "#app",
        data: {
          message: "你好呀",
        },
        methods: {},
        components: {
          con: {
            template: "#tp",
          },
        },
      });
    </script>
  </body>
</html>
